const { no, ok } = require('../../utils/utlis');

const settingService = require('../../services/admin/settingService');
module.exports = {
	list: async (req, res, next) => {
		try {
			let data = await settingService.list();
			res.send(ok(data));
		} catch (error) {
			res.send(no(error.message));
		}
	},
	add: async (req, res, next) => {
		try {
			let { id, url,filename,title } = req.body;
			await settingService.add(id, url,filename,title);
			res.send(ok());
		} catch (error) {
			res.send(no(error.message));
		}
	},
	edit: async (req, res, next) => {
		try {
			let { id, url,filename,title } = req.body;
			await settingService.edit(id, url,filename,title);
			res.send(ok());
		} catch (error) {
			res.send(no(error.message));
		}
	},
	detail: async (req, res, next) => {
		try {
			let { id } = req.body;
			let obj = await settingService.detail(id);
			res.send(ok(obj));
		} catch (error) {
			res.send(no(error.message));
		}
	},
	del: async (req, res, next) => {
		try {
			let { id } = req.body;
			await settingService.del(id);
			res.send(ok());
		} catch (error) {
			res.send(no(error.message));
		}
	}
};
